<!DOCTYPE html>
<html>
<head>
    <title>    arm play</title>
    <script src="__STYLE__/amr.js/Libamr-2.2.5.min.js"></script>
    <script src="__STYLE__/amr.js/RongIMVoice-2.2.5.min.js"></script>
    <script src="__STYLE__/amr.js/jquery-3.1.1.js"></script>

</head>
<body>
<h1>amr play</h1>

<button id="unmuteButton" sw="0">start play</button>
<script type="text/javascript">
        
		/*
			初始化声音库
		*/
		var RongIMVoice = RongIMLib.RongIMVoice;
			RongIMVoice.init();

		/*
			* play() 播放音频消息
			* 参数 voice 为 amr 格式的 base64
			* 示例: voice = "IyFBTVIKLNEafAAeef/hgmeAH8AD...";
		*/

		function play(voice){
			if(voice){
				var duration = voice.length/1024;    // 音频持续大概时间(秒)
				RongIMVoice.preLoaded(voice, function(){
				    RongIMVoice.play(voice,duration);
				});
			}else{
				console.error('请传入 amr 格式的 base64 音频文件');
			}
		}
		function stop(voice){
			if(voice){
				//停止播放
				RongIMLib.RongIMVoice.stop(voice);
			}else{
				console.error('请传入 amr 格式的 base64 音频文件');
			}
		}
		/*
		    * messageData 为音频示例数据，在 voice-amr-base64.json 中
		    * 通过监听 button 的点击事件获取 消息的唯一标示 messageUId
		    * 根据 messageUId 获取到 音频消息的 base64 数据，然后执行 play() 方法
		*/

		$("#unmuteButton").on("click",function(){
			str="IyFBTVIKLNEafAAeef/hgmeAH8AD/+ggggAALMWpzAAf+f/hgmYAH8AD/+ggggAALNEazAAf+f/hgmYAH8AD/+ggggAALMWpzAAf+f/hgmYAH8AD/+ggggAALNEazAAf+f/hgmYAH8AD/+ggggAALD6uNMj8wOpLVu1gW4hdzeh/fgiuLHMNjlqB01YTTpJe9NGDEmhhMt5CLHqXRlury9xLLpjD/pX9Ks4rQp0mLHsNQHmADNTQZqfpPC5pkkLcwhoqLKCAnB/gTagG1m+/f3Pw4reCPGlKLHqj4D3Au9v4R+KR4eUXids9B/42LKK2iFuxjZYZCs5rg+GeUdvDP0FILJICnQ7wHNvO/0SGcNYA9nqe6IIcLHXt4B/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aXKtzoGu/4LGChiB74PqYx8vfcFzb5RIXLElJ8LDtBDB+xLgH31WphnpZZYq7gC+U4LFARiB/BvoHn4nUBq5IxiHUcWXQALD+NzB/IHCHjIENi36E9hq3UHmrULEVmjh8gtNoPesplmIiLWVoaE0cILDxy6h8wlLGckBVjqrAdNSyms1yWLC/vzB8sMyTlYEcINn5Zn0euUYvQLGVc6h9iptSIMSNcK+1TjIhLgqzGLCQ3zB+CTFymQDGM8NCuFyw+SPzCLCoRdh+hPc4VGR6MKl2mWTdkbEb0LCahiB5wU0jY6w/4GOMpOYIcsnZMLGA2iB9RlYNverwxMehuyHcILtSkLFEriB+gnwtAo91mdBaxeaM4Q3AWLCcrqB8i3yytU72dCX4Wy0s79H9oLDqwRB/EEePX8iznNuDhJ5rLese4LJIkiB/BW8S6Yo6gnbCAfbNxYVOqLFOGqB/5IaTBm34QwqfrSV3A85rOLEaW6h7A1ksDCUc6bwmDE48Gtew6LEeWAh8RBYG+vNTjDAsLHIyPVIDiLEa26h+YhcRmKCbO9LPsyr6I+inMLFftqBxm1/xu68tWr9W9ndDrL6wALC+PRh/YVcNlxsAK5oWHuidPmaqMLD62zB6kFNxWgLDRFldLUMsJY0QQLEXHdh7AE8IAWYP8d8Ec5ToLZwW8";
			// var messageUId = $(this).attr('messageUId');
			// var voiceData = messageData[messageUId].content.content;    //获取 base64 音频文件
			// // 播放声音
			// play("{$b}");
			if($(this).attr('sw')==1){
				stop(str);
				$(this).attr('sw',0);
			}else{
				play(str);
				$(this).attr('sw',1);
			}
			
			
		});


    </script>
</body>
</html>